package cn.ncupyh.comptest;

import java.util.Random;
import java.util.Scanner;

//猜数字
public class GuessNumber {
    public static void main(String[] args) {
        System.out.println("猜数字游戏正式开始~");
        Scanner s = new Scanner(System.in);
        Random r = new Random();
        int randNum = r.nextInt(100);//[0,100)  生成0-99的数字(100个数字)
        int randNum1 = r.nextInt(100) + 100;//[100,200)  生成100-199的数字(100个数字)

        int randNum2 = (int) (Math.random() * 10);//[0,9)==10个数字
        //System.out.println(randNum2);

        while(true){
            System.out.println("请输入你猜的数字:>");
            int in = s.nextInt();

            if(in >randNum){
                System.out.println("猜大了!");
            }else if(in == randNum){
                System.out.println("猜对了~");
                break;
            }else if(in < randNum){
                System.out.println("猜小了!");
            }
        }
    }
}
